package com.javafm.devices.controller;

import com.javafm.devices.client.ParkClient;
import com.javafm.devices.dto.DevicesListResponse;
import com.javafm.devices.service.DevicesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DevicesController {

    @Autowired
    private DevicesService devicesService;
    @Autowired
    private ParkClient parkClient;

    @GetMapping("/call-park-list")
    public String callParkList() {
        // 测试在devices服务里面调用park服务的接口
        return parkClient.parkList();
    }

    @GetMapping("/devices-list/{park_id}")
    public DevicesListResponse devicesList(@PathVariable("park_id") int parkId) {
        return new DevicesListResponse(0, "success", devicesService.getDevicesList(parkId));
    }
}
